package com.ssy.lingxi.contract.repository;

import com.ssy.lingxi.contract.entity.ContractPurchaseMaterielDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

import java.util.List;

/**
 * 合同采购物料
 * @author 伍将
 * @date 2021/2/8
 * @version 2.0.0
 */
public interface ContractPurchaseMaterielRepository extends JpaRepository<ContractPurchaseMaterielDO, Long>, JpaSpecificationExecutor<ContractPurchaseMaterielDO>, QuerydslPredicateExecutor<ContractPurchaseMaterielDO> {

    /**
     * 根据合同id查询采购物料
     * @author 伍将
     * @date 2021/2/25
     * @param contractId: 合同id
     * @return 采购物料列表
     **/
    List<ContractPurchaseMaterielDO> findByContractId(Long contractId);

    /**
     * 根据合同id删除采购物料
     * @author 伍将
     * @date 2021/3/3
     * @param contractId: 合同id
     * @return 无
     **/
    void deleteByContractId(Long contractId);

    /**
     * 根据合同id与采购物料id查询采购物流
     * @author 伍将
     * @date 2021/3/19
     * @param contractId: 合同id
     * @param materielIdList: 采购物料id
     * @return 采购物料列表
     **/
    List<ContractPurchaseMaterielDO> findByContractIdAndIdIn(Long contractId, List<Long> materielIdList);

    /**
     * 根据合同id与采购物料no查询采购物流
     * @author 伍将
     * @date 2021/3/19
     * @param contractId: 合同id
     * @param materielNoList: 采购物料no
     * @return 采购物料列表
     **/
    List<ContractPurchaseMaterielDO> findByContractIdAndMaterielNoIn(Long contractId, List<String> materielNoList);

    /**
     * 根据采购物料编码查询采购物料信息
     * @author lxc
     * @date 2022/3/28
     * @param materielNo: 采购物料编码
     * @return 采购物料信息
     **/
    List<ContractPurchaseMaterielDO> findByMaterielNo(String materielNo);
}
